//
//  SubjectTableViewCell.m
//  ITrip
//
//  Created by dllo on 15/5/22.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "SubjectTableViewCell.h"
@implementation SubjectTableViewCell

- (void) dealloc{
    [_name release];
    [_title release];
    [_image_url release];
    [_subjectModel release];
    [super dealloc];
}


- (void) setSubjectModel:(SubjectModel *)subjectModel{

    [self.image_url setImageWithURL:[NSURL URLWithString:subjectModel.image_url] placeholderImage:[UIImage imageNamed:@"defaultPicture"]];
    
    self.name.text = subjectModel.name;
    
    self.title.text = subjectModel.title;

}

- (instancetype) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createCell];
    }
    return self;
}



- (void) createCell{
    self.image_url = [[UIImageView alloc] init];
    [self.contentView addSubview:self.image_url];
    [self.image_url release];

    self.name = [[UILabel alloc] init];
    [self.contentView addSubview:self.name];
    [self.name release];
    
    self.title = [[UILabel alloc] init];
    [self.contentView addSubview:self.title];
    [self.title release];
    
    

}

- (void) layoutSubviews{
    
    [super layoutSubviews];
    
    self.name.frame = CGRectMake(20, 150, self.contentView.frame.size.width - 40, 40);
    self.name.font = [UIFont systemFontOfSize:24];
    self.name.textColor = [UIColor colorWithRed:255 / 255.0 green:255 / 255.0 blue:255 / 255.0 alpha:1];
//    self.name.backgroundColor = [UIColor greenColor];
    
    self.title.frame = CGRectMake(20, 190, self.contentView.frame.size.width - 40, 25);
    self.title.font = [UIFont systemFontOfSize:14];
    self.title.textColor = [UIColor colorWithRed:255 / 255.0 green:255 / 255.0 blue:255 / 255.0 alpha:1];
//    self.title.backgroundColor = [UIColor blueColor];
    
    self.image_url.frame = CGRectMake(10, 10, self.contentView.frame.size.width - 20, self.contentView.frame.size.height - 10);
    self.image_url.layer.cornerRadius = 4;
    self.image_url.layer.masksToBounds = YES;
    
    self.image_url.backgroundColor = [UIColor redColor];
}






- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
